const fs = require('fs')

function Promisify(fn) {
  return function (...args) {
    return new Promise((resolve, reject) => {
      fn(...args, (err, res) => {
        if (err) return reject(err)
        resolve(res)
      })
    })
  }
}

const read = Promisify(fs.readFile)

read('test.txt').then(data => {
  console.log(data.toString())
}).catch(err => {
  console.log(err)
})

async function test() {
  try {
    const data = await read('./你好啊.md')
    console.log(data.toString())
  } catch (ex) {
    console.log(ex)
  }
}

test()
